<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #box{
            width: 400px;
            height: 400px;
            border: 1px solid #000;
            background-color: #09f;
        }
    </style>
</head>
<body>
    <h1>JS 鼠标 按下-松开-移动</h1>
    <hr>

    <div id="box"></div>

    <script>
    // - onmousedown    鼠标按下触发
    box.onmousedown = function () {
        this.style.backgroundColor = '#f90';
    }
    // - onmouseup      鼠标松开触发
    box.onmouseup = function () {
        this.style.backgroundColor = '#09f';
    }
    // - onmousemove    鼠标移动触发
    box.onmousemove = function (en) {
        console.log('我在移动: ' + Math.random());
        document.title = en.clientX + ','+en.clientY;
    }
    </script>
</body>
</html>